﻿/**
 * FieldConfig.java	1.0 2007 五月 29 15:31:17,创建
 */

package org.in4j.search.index;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *
 * @author 杨帆
 * @version 1.0 2007 五月 29 15:31:17,创建
 */
public class FieldConfig
{
	@SuppressWarnings("unused")
	private static final Log log = LogFactory.getLog(FieldConfig.class);
	public static final FieldConfig DEFAULT = defaultConfig();
	private String name;
	private float boost;
	private String fieldType;
	private String datePattern;
	private Store store;
	private Index index;

//	public static Store STORE;

	/**
	 * 存储方式
	 * @see org.apache.lucene.document.Field.Store
	 */
	public enum Store
	{
		/**
		 * 保存原始的字段值.用于短文本,比如文档标题之类需要显示的结果
		 */
		YES("YES"),
		/**
		 * 不存储此字段的值到到索引文件
		 */
		NO("NO"),
		/**
		 * 把索引压缩后进行保存,用于长文档和二进制字段
		 */
		COMPRESS("COMPRESS");
		Store(String value){};
	}

	/**
	 * 索引方式
	 * @see org.apache.lucene.document.Field.Index
	 */
	public enum Index
	{
		NO("NO"),
		TOKENIZED("TOKENIZED"),
		UN_TOKENIZED("UN_TOKENIZED"),
		NO_NORMS("NO_NORMS");
		Index(String value){};
	}

	public static final int INDEX_TOKENIZED = 0;

	public String getFieldType()
	{
		return fieldType;
	}

	private static FieldConfig defaultConfig()
	{
		FieldConfig config = new FieldConfig();
		config.setBoost(1.0f);
		config.setFieldType("String");
		config.setDatePattern(null);
		return config;
	}

	public void setFieldType(String fieldType)
	{
		this.fieldType = fieldType;
	}

	public String getDatePattern()
	{
		return datePattern;
	}

	public void setDatePattern(String datePattern)
	{
		this.datePattern = datePattern;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public void setBoost(float boost)
	{
		this.boost = boost;
	}

	public float getBoost()
	{
		return boost;
	}

	public String getName()
	{
		return name;
	}

	public Store getStore()
	{
		return store;
	}

	public void setStore(Store store)
	{
		this.store = store;
	}

	public Index getIndex()
	{
		return index;
	}

	public void setIndex(Index index)
	{
		this.index = index;
	}



}
